package io.github.syske.springbootjdbcmybatisdemo.controller;

import io.github.syske.springbootjdbcmybatisdemo.common.ResultObject;
import io.github.syske.springbootjdbcmybatisdemo.dao.MallDao;
import io.github.syske.springbootjdbcmybatisdemo.dao.TempOpDao;
import io.github.syske.springbootjdbcmybatisdemo.entity.Station;
import io.github.syske.springbootjdbcmybatisdemo.entity.vo.MItemVO;
import io.github.syske.springbootjdbcmybatisdemo.entity.vo.MallVO;
import io.github.syske.springbootjdbcmybatisdemo.service.impl.MallLocateServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
public class MallController {

    @Autowired
    MallLocateServiceImpl mallLocateService;

    @Autowired
    TempOpDao tempOpDao;

    @Autowired
    MallDao mallDao;

    @RequestMapping("api/getMItem")
    public Object getMItem(){
        List<MItemVO> mItem = mallDao.getMItem2();
        ResultObject resultObject = new ResultObject();
        resultObject.data=mItem;
        return resultObject;
    }

    @RequestMapping("api/getMAllByItem")
    public Object getMAllByItem(@Param("item_code") String item_code){
        Map<String,Object> map = new HashMap<>();
        map.put("m_item",item_code.toString());
        List<MallVO> mall = mallDao.getAllByTem(map);
      //  Set set = new HashSet<>(mall);
        ResultObject resultObject = new ResultObject();
        resultObject.data = mall;
        return resultObject;
    }

    @RequestMapping("api/getSttInfo")
    public Object getSttInfo(){
        List<Station> sttInfo = tempOpDao.getSttInfo();
        ResultObject resultObject = new ResultObject();
        resultObject.data = sttInfo;
        return resultObject;
    }

}
